import request from '@/utils/request'

// 登录
export function fetchList(data, scope) {
  return request({
    url: `/kd_manage/resource/${scope}/list`,
    method: 'post',
    data: data
  })
}

export function getResource(resourceId, scope) {
  return request({
    url: `/kd_manage/resource/${scope}/info`,
    method: 'get',
    params: { resourceId }
  })
}

export function addResource(data, scope) {
  return request({
    url: `/kd_manage/resource/${scope}/add`,
    method: 'post',
    data: data
  })
}
export function delResource(resourceId, scope) {
  const params = { resourceId }
  return request({
    url: `/kd_manage/resource/${scope}/delete`,
    method: 'post',
    params: params
  })
}

export function updateResource(id, data, scope) {
  data.id = id
  return request({
    url: `/kd_manage/resource/${scope}/edit`,
    method: 'post',
    data: data
  })
}

// 登录
export function getApiGroupList(scope) {
  return request({
    url: `/kd_manage/api_group/${scope}/list`,
    method: 'get'
  })
}

export function addApiGroup(scope, data) {
  return request({
    url: `/kd_manage/api_group/${scope}/add`,
    method: 'post',
    data: data
  })
}
export function delApiGroup(scope, id) {
  const data = { id }
  return request({
    url: `/kd_manage/api_group/${scope}/delete`,
    method: 'post',
    data: data
  })
}

export function updateApiGroup(scope, data) {
  return request({
    url: `/kd_manage/api_group/${scope}/update`,
    method: 'post',
    data: data
  })
}
